<?php

function user($id) {
	try {
		$user = MantisUserTable::LoadById($id);
	
		return $user->Realname;
	} catch (Exception $e) {
		return "Unassigned";
	}
}


	$g_priority				= parseEnum('10:none,20:low,30:normal,40:high,50:urgent,60:immediate');
	/**
	 *
	 * @global string $g_severity
	 */
	$g_severity				= parseEnum('10:feature,20:trivial,30:text,40:tweak,50:minor,60:major,70:crash,80:block');

	/**
	 *
	 * @global string $g_reproducibility
	 */
	$g_reproducibility		= parseEnum('10:always,30:sometimes,50:random,70:have not tried,90:unable to duplicate,100:N/A');

	/**
	 *
	 * @global string $g_status
	 */
	$g_status				= parseEnum('10:new,20:bounce,30:acknowledged,40:confirmed,50:assigned,60:next build,70:test,80:resolved,90:closed');

	/**
	 * @@@ for documentation, the values in this list are also used to define variables in the language files
	 *  (e.g., $s_new_bug_title referenced in bug_change_status_page.php )
	 * Embedded spaces are converted to underscores (e.g., "working on" references $s_working_on_bug_title).
	 * they are also expected to be english names for the states
	 * @global string $g_resolution
	 */
	$g_resolution			= parseEnum('10:open,20:fixed,30:reopened,40:unable to duplicate,50:not fixable,60:duplicate,70:not a bug,80:suspended,90:wont fix');

	/**
	 *
	 * @global string $g_projection
	 */
	$g_projection			= parseEnum('10:none,30:tweak,50:minor fix,70:major rework,90:redesign');

	/**
	 *
	 * @global string $g_eta
	 */
	$g_eta					= parseEnum('10:none,20:< 1 day,30:2-3 days,40:< 1 week,50:< 1 month,60:> 1 month');


function parseEnum($str) {
	$vals = explode(",", $str);

	$ret = array();

	$parts = array();
	for ($i=0; $i<count($vals); $i++) {
		$parts = explode(":", $vals[$i]);
		$ret[intVal($parts[0])] = $parts[1];
	}

	return $ret;
}

function priority($id) {
	global $g_priority;

	return $user->Realname;
}

function severity($id) {
	$user = MantisUserTable::LoadById($id);

	return $user->Realname;
}

function status($id) {
	$user = MantisUserTable::LoadById($id);

	return $user->Realname;
}

function category($id) {
	$user = MantisCategoryTable::LoadById($id);

	return $user->Name;
}

function versionstatus($status) {
	
$VERSION_STATUS_NEW = 2;
$VERSION_STATUS_PRODUCTION = 3;
$VERSION_STATUS_PREVIOUS = 4;

switch ($status) {
	case 2 :
		return "Latest";
	case 3 :
		return "Production";
	case 4 :
		return "Previous Release";
}
}


?>